<%--
  Created by IntelliJ IDEA.
  User: xianfei
  Date: 15-6-24
  Time: 下午2:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>周次划分</title>
    <style>
        .weekselected {
            background-color: #68b996;
        }

        .houseInfoselected {
            background-color: #68b996;
        }
    </style>
</head>
<body>

<div class="backend">
    <table class="table table-striped" style="height: 45px;">
        <tr>
            <td style="width:10%">度假屋：</td>
            <td style="width:400px;">
                <select id="houseInfoDTO">
                    <c:forEach items="${houseInfoDTOs}" var="houseInfoDTO">
                        <option value="${houseInfoDTO.guid}">${houseInfoDTO.name}</option>
                    </c:forEach>
                </select>
            </td>
            <td style="width:8%">周次：</td>
            <td id="houseInfoContent">
                <select id="week">
                    <option value="HUANGJINZHOU">黄金周</option>
                    <option value="WANGJIZHOU">旺季周</option>
                    <option value="PINGJIZHOU">平季周</option>
                    <option value="DANJIZHOU">淡季周</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>库存：</td>
            <td>
                <input type="text" value="${houseWeek.totalNum}" id="totalNum">
            </td>
            <td>价格：</td>
            <td><input type="text" value="${houseWeek.price}" id="weekprice"/></td>
        </tr>
        <tr>
            <td>描述:</td>
            <td>
                <textarea  id="description" cols="30" rows="3" >${houseWeek.description}</textarea>
            </td>
            <td></td>
            <td></td>
        </tr>
    </table>
    <input type="button" class="btn btn-success" value="保存" id="submit"/>
    <input type="button" id="backList" class="btn btn-info" value="返回列表">
</div>
<script>
    $("#submit").click(function () {
        var guid = $("#houseInfoDTO").val();
        var week = $("#week").val();
        var price = $("#weekprice").val();
        var description = $("#description").val();
        var totalNum = $("#totalNum").val();
        $.ajax({
            url: '/house_week/addweek',
            type: 'post',
            dataType: 'text',
            data: {houseInfoguid: guid, week: week, price: price, description: description, totalNum: totalNum},
            success: function () {
                location.reload();

            }
        })
    });
    $("#week").val("${week}");
    $("#houseInfoDTO").val("${houseInfoGuid}");
    $("#houseInfoContent select").change(function () {
                var guid = $("#houseInfoDTO").val();
                var week = $("#week").val();
                location = '/house_week/findhouseweek/' + guid + "/" + week;
            }
    )

</script>
</body>
</html>